<template>
	<div class="ToPassWord">
		<div class="head_two">
			<i class="iconfont icon-Goback" @click="$router.back(-1)"></i>
		</div>
		<div class="login_cont">
			<p class="title">重置密码</p>
			<ul class="logUl">
				<li><input type="password" name="" placeholder="设置登录密码" v-model="onePwsd"></li>
				<li><input type="password" name="" placeholder="再次输入登录密码" v-model="twoPwsd"> </li>
				{{filterPhone}}
			</ul>
			<button class="button" :class="{backg:isShow}" @click="getRegister()">完成</button> 
		</div>
	</div>
</template>
<script type="text/javascript">
import md5 from 'js-md5';
import Qs from 'qs';
import { Toast } from 'mint-ui';
	export default{
		name:'ToPassWord',
		data(){
			return{
				onePwsd:'',
				twoPwsd:'',
				isShow:false
			}
		},
		created:function(){
			 this.urls=this.$store.state.urls;
		},
		mounted:function(){
			this.myPhone=this.$route.params.phone;
			this.yzm=this.$route.params.yzm; 
		},
		computed:{
			filterPhone:function() {
				if (this.onePwsd.length>5) {
					this.isShow=true
				}else{
					this.isShow=false
				}
			}
		}, 
		methods:{
			getRegister:function(){
				if (this.onePwsd==this.twoPwsd) { 
					this.$http.post(this.urls+"/WorkMembers/v1.0/EditPwdByVer",Qs.stringify({
					  "MembersID":this.myPhone,
					  "PwdType":"login",
					  "Ver": this.yzm,
					  "Pwd": md5(this.twoPwsd)
					})
				).then((res)=>{ 
					console.log(res.data);
				    Toast(res.data.Return_Mess);
				    setTimeout(this.routerUrl,3000)
				  }).catch((err)=>{
				    console.log(err);
				  });
				}else{
					Toast("请保持密码一致~");
				} 
			},
			routerUrl:function(){
				this.$router.push({path:'/LoginAll/ToLogin'}) 
			} 
		}
	}
</script>
<style scoped> 
	.logUl{
		width: 100%;
	}
	.logUl li{
		border-bottom: 1px solid #e8e8e8;
		height: 1.28rem;
	}
	.logUl li input{
		width: 100%;
		height: 100%;
	 	border:0;
		outline: none;
		text-indent: 0.3333333333rem;
		font-size: 0.4rem;
	}
	.button{
		width: 100%;
		outline: none;
		height:1.0666666667rem;
		color: #fff;
		font-size: 0.4533333333rem;
		background-color: #ccc;
		border:0;
		border-radius: 0.0666666667rem;
		margin:0.6666666667rem 0;
	}
	.backg{
		background-color: #db2023;
	} 
</style>